package org.jeecgframework.web.service.impl;
import org.jeecgframework.core.common.service.impl.CommonServiceImpl;
import org.jeecgframework.web.service.ZyInstallRecordServiceI;
import org.jeecgframework.web.system.pojo.base.ZyInstallRecordEntity;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.UUID;
import java.io.Serializable;

@Service("zyInstallRecordService")
@Transactional
public class ZyInstallRecordServiceImpl extends CommonServiceImpl implements ZyInstallRecordServiceI {

	
 	public <T> void delete(T entity) {
 		super.delete(entity);
 		//执行删除操作配置的sql增强
		this.doDelSql((ZyInstallRecordEntity)entity);
 	}
 	
 	public <T> Serializable save(T entity) {
 		Serializable t = super.save(entity);
 		//执行新增操作配置的sql增强
 		this.doAddSql((ZyInstallRecordEntity)entity);
 		return t;
 	}
 	
 	public <T> void saveOrUpdate(T entity) {
 		super.saveOrUpdate(entity);
 		//执行更新操作配置的sql增强
 		this.doUpdateSql((ZyInstallRecordEntity)entity);
 	}
 	
 	public <T> void saveOrUpdateForCp(T entity) {
 		super.saveOrUpdate(entity);
 		//执行更新操作配置的sql增强
// 		this.doUpdateSql((ZyInstallRecordCpEntity)entity);
 	}
 	
 	/**
	 * 默认按钮-sql增强-新增操作
	 * @param id
	 * @return
	 */
 	public boolean doAddSql(ZyInstallRecordEntity t){
	 	return true;
 	}
 	/**
	 * 默认按钮-sql增强-更新操作
	 * @param id
	 * @return
	 */
 	public boolean doUpdateSql(ZyInstallRecordEntity t){
	 	return true;
 	}
 	/**
	 * 默认按钮-sql增强-删除操作
	 * @param id
	 * @return
	 */
 	public boolean doDelSql(ZyInstallRecordEntity t){
	 	return true;
 	}
 	
 	/**
	 * 替换sql中的变量
	 * @param sql
	 * @return
	 */
 	public String replaceVal(String sql,ZyInstallRecordEntity t){
 		sql  = sql.replace("#{id}",String.valueOf(t.getId()));
 		sql  = sql.replace("#{no}",String.valueOf(t.getNo()));
 		sql  = sql.replace("#{dp_model}",String.valueOf(t.getDpModel()));
 		sql  = sql.replace("#{sn}",String.valueOf(t.getSn()));
 		sql  = sql.replace("#{province}",String.valueOf(t.getProvince()));
 		sql  = sql.replace("#{city}",String.valueOf(t.getCity()));
 		sql  = sql.replace("#{customer_planed_arrival_date}",String.valueOf(t.getCustomerPlanedArrivalDate()));
 		sql  = sql.replace("#{actual_send_date}",String.valueOf(t.getActualSendDate()));
 		sql  = sql.replace("#{send_place}",String.valueOf(t.getSendPlace()));
 		sql  = sql.replace("#{belong_dealer}",String.valueOf(t.getBelongDealer()));
 		sql  = sql.replace("#{en_customer_name}",String.valueOf(t.getEnCustomerName()));
 		sql  = sql.replace("#{cn_customer_name}",String.valueOf(t.getCnCustomerName()));
 		sql  = sql.replace("#{cn_address}",String.valueOf(t.getCnAddress()));
 		sql  = sql.replace("#{postcode}",String.valueOf(t.getPostcode()));
 		sql  = sql.replace("#{contacter}",String.valueOf(t.getContacter()));
 		sql  = sql.replace("#{area_code}",String.valueOf(t.getAreaCode()));
 		sql  = sql.replace("#{tel_no}",String.valueOf(t.getTelNo()));
 		sql  = sql.replace("#{email}",String.valueOf(t.getEmail()));
 		sql  = sql.replace("#{cellphone_no}",String.valueOf(t.getCellphoneNo()));
 		sql  = sql.replace("#{technical_director}",String.valueOf(t.getTechnicalDirector()));
 		sql  = sql.replace("#{mobile_no}",String.valueOf(t.getMobileNo()));
 		sql  = sql.replace("#{house}",String.valueOf(t.getHouse()));
 		sql  = sql.replace("#{seats}",String.valueOf(t.getSeats()));
 		sql  = sql.replace("#{screen_type}",String.valueOf(t.getScreenType()));
 		sql  = sql.replace("#{screen_gain}",String.valueOf(t.getScreenGain()));
 		sql  = sql.replace("#{scope_width}",String.valueOf(t.getScopeWidth()));
 		sql  = sql.replace("#{scope_height}",String.valueOf(t.getScopeHeight()));
 		sql  = sql.replace("#{flat_width}",String.valueOf(t.getFlatWidth()));
 		sql  = sql.replace("#{flat_height}",String.valueOf(t.getFlatHeight()));
 		sql  = sql.replace("#{play_distance}",String.valueOf(t.getPlayDistance()));
 		sql  = sql.replace("#{wide_screen_lens_ratio}",String.valueOf(t.getWideScreenLensRatio()));
 		sql  = sql.replace("#{cover_lens_ratio}",String.valueOf(t.getCoverLensRatio()));
 		sql  = sql.replace("#{select_lens}",String.valueOf(t.getSelectLens()));
 		sql  = sql.replace("#{threed_model}",String.valueOf(t.getThreedModel()));
 		sql  = sql.replace("#{threed_sn}",String.valueOf(t.getThreedSn()));
 		sql  = sql.replace("#{audio}",String.valueOf(t.getAudio()));
 		sql  = sql.replace("#{special_line_length}",String.valueOf(t.getSpecialLineLength()));
 		sql  = sql.replace("#{installed_date}",String.valueOf(t.getInstalledDate()));
 		sql  = sql.replace("#{initial_brightness}",String.valueOf(t.getInitialBrightness()));
 		sql  = sql.replace("#{initial_blower}",String.valueOf(t.getInitialBlower()));
 		sql  = sql.replace("#{installer}",String.valueOf(t.getInstaller()));
 		sql  = sql.replace("#{installation_company}",String.valueOf(t.getInstallationCompany()));
 		sql  = sql.replace("#{warranty_period}",String.valueOf(t.getWarrantyPeriod()));
 		sql  = sql.replace("#{server_model}",String.valueOf(t.getServerModel()));
 		sql  = sql.replace("#{server_sn}",String.valueOf(t.getServerSn()));
 		sql  = sql.replace("#{comment}",String.valueOf(t.getComment()));
 		sql  = sql.replace("#{import_date}",String.valueOf(t.getImportDate()));
 		sql  = sql.replace("#{create_name}",String.valueOf(t.getCreateName()));
 		sql  = sql.replace("#{create_by}",String.valueOf(t.getCreateBy()));
 		sql  = sql.replace("#{create_date}",String.valueOf(t.getCreateDate()));
 		sql  = sql.replace("#{update_name}",String.valueOf(t.getUpdateName()));
 		sql  = sql.replace("#{update_by}",String.valueOf(t.getUpdateBy()));
 		sql  = sql.replace("#{update_date}",String.valueOf(t.getUpdateDate()));
 		sql  = sql.replace("#{UUID}",UUID.randomUUID().toString());
 		return sql;
 	}
}